package com.javabasic.algorithm.leetcode;

/**
 * @author mir.xiong
 * @version 1.0
 * @description
 * @see
 * @since Created by work on 2021/12/28 11:53 下午
 */
public class ExcelSheetColumnNumber {

    /**
     * 26进制转为10进制
     * @param columnTitle
     * @return
     */
    public int titleToNumber(String columnTitle) {
        int len = columnTitle.length(), num, result = 0;
        for (int i = 0; i < len; i++) {
            num = columnTitle.charAt(i) - 'A' + 1;
            result = result*26 + num;
        }
        return result;
    }
}
